import time as t
class Mytime:
    def __init__(self):
        self.unit=['年','月','天','小时','分钟','秒']
        self.sambo=0
        self.begin=0
        self.end=0
        self.passtime=[]
        self.prompt='计时器没有开始！'
        self.defaultcounter=t.perf_counter()
    def __str__(self):
        return self.prompt
    __repr__=__str__
    def __add__(self, other):
        prompt='总共运行了'
        sum = self.passtime+other.passtime
        prompt+=str(sum)+self.unit[5]
        return prompt
    def settime(self,counter=t.perf_counter()):
        self.defaultcounter=counter
    def start(self):
        self.begin=t.perf_counter()
        self.prompt='请输入STOP停止计时器！'
        print('计时开始！')
    def stop(self):
        if not self.start:
            print('计时器没有运行！')
        else:
            self.end=t.perf_counter()
            print('计时结束！')
            self._calctime()
    def _calctime(self):
        self.prompt='共运行了'
        # for index in range(6):
        self.passtime=self.end-self.begin
        self.prompt+=(str(self.passtime)+self.unit[5])
t1=Mytime()
t2=Mytime()
t1.start()
input('等待，按回车继续')
t1.stop()
t1
print(t1)
t2.start()
input('等待，按回车继续')
t2.stop()
t2
print(t2)
print(t1+t2)

